# -*- coding: utf-8 -*-
# @Time    : 2022/5/24 1:08
# @Author  : zhangping
# @Email   : 2432115515@qq.com
# @File    : page_font_login.py
# @Software: PyCharm
"""
登录页面
"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage
class LoginPage(BasePage):
    #定位器
    ele_username_locator=(By.NAME,"username")
    ele_password_locator=(By.NAME,"password")
    ele_login_btn_locator=(By.NAME,"submit")
    # 找到我的账户
    ele_my_account_locator = (By.XPATH, '/html/body/div[1]/div/div/a[1]')
    # 找到不登录直接购买按钮
    ele_nodl_btn_locator = (By.XPATH, '//*[@id="loginForm"]/table/tbody/tr[5]/td/div/input[2]')
    #操作
    def input_username(self):
        """输入用户名"""
        self.driver.find_element(*self.ele_username_locator).send_keys("lwx")

    def input_password(self):
        """输入密码"""
        self.driver.find_element(*self.ele_password_locator).send_keys("123456")

    def login_btn(self):
        """点击登录"""
        self.driver.find_element(*self.ele_login_btn_locator).click()

    def login(self):
        """聚合登录"""
        self.input_username()
        self.input_password()
        self.login_btn()
    def currenturl(self):
        """获取登录界面的url"""
        current_url = self.driver.current_url
        return current_url
    def No_login(self):
        """不登录"""
        self.driver.find_element(*self.ele_nodl_btn_locator).click()



